using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Unregistry.Properties;

namespace Unregistry
{
    public partial class MainView : Form
    {
        #region Properties
        public TextBox textboxRegistryFile
        {
            get { return this._textboxRegistryFile; }
        }

        public Button buttonOpenFileDialog
        {
            get { return this._buttonOpenFileDialog; }
        }

        public CheckBox checkboxRemoveEmptyKeys
        {
            get { return this._checkboxRemoveEmptyKeys; }
        }

        public Button buttonRemove
        {
            get { return this._buttonRemove; }
        }

        public Button buttonExit
        {
            get { return this._buttonExit; }
        }

        public OpenFileDialog OpenFileDialog
        {
            get { return this._OpenFileDialog; }
        }
        #endregion

        #region Methods
        public MainView()
        {
            InitializeComponent();
        }

        public void ShowErrorProvider(
            Control theControl,
            string theMessage)
        {
            this._ErrorProvider.SetError(
                theControl, theMessage);
        }

        public void ClearErrorProvider()
        {
            this._ErrorProvider.Clear();
        }
        
        public void ClearLog()
        {
            this._gridLog.Rows.Clear();
        }

        public void AddLogMessage(
            LogAction theLogAction,
            string theMessage) 
        {
            this._gridLog.ClearSelection();

            Bitmap theIcon;

            switch(theLogAction)
            {
                case LogAction.Key:
                    theIcon = Resources.folder_delete;
                    break;
                case LogAction.Value:
                    theIcon = Resources.page_white_delete;
                    break;
                default:
                    theIcon = Resources.information;
                    break;
            }

            this._gridLog.Rows.Add(
                theIcon,
                DateTime.Now.ToString("HH:mm:ss"),
                theMessage);

            this._gridLog.Rows[0].Cells[0].Selected = false;
        }

        public bool IsFormValid()
        {
            this.ClearErrorProvider();

            if (String.IsNullOrEmpty(
                this._textboxRegistryFile.Text))
            {
                this.ShowErrorProvider(
                    this._buttonOpenFileDialog,
                    "Required!");

                return false;
            }
            return true;
        }
        #endregion
    }
}